*********************************************************************
* Public Preferences for Intergroup Assistance in Conflicts Facing  *
* Joint External Threats: Lessons from COVID-19 in Israel			*
* Liran Harsgor and Alon Yakter  									*
* Journal of Conflict Resolition									*
*                                                                   *
* Replication code - regression models 				            	* *********************************************************************
* The analysis was performed with Stata 17. For model presentation, *
* users should install the estout package							* 
* (command line: "ssc install estout, replace").					*
* 																	*
* The analysis uses two datasets using Stata's fframe options, 		*
* available since version 16 and onward. With earlier versions, 	*
* users should replace frame commands with manual reloads of the	*
* relevant datasets using the "use" command. 						*
*																	*
* to load the data (the "use" command), users should place the .dta	*
* file in their Stata working directory (or type the full file 		*
* paths as saved on their computer).                      			*
*********************************************************************


*********************************************
* set up data frames based on two datasets	*
* (IDI survery and two-wave survey)			*
*********************************************
frames reset
* April survey (IDI)
use "IDI survey April.dta", replace
frame rename default April
* July and October survey (2-wave panel)
frame create JulOct
frame change JulOct
use "Panel survey July+October.dta" , replace
frames dir

*******************************
* survey tabulation (table 2) *
*******************************
** tabulation
frame change April
recode involvement (1/2 = 1)(3/4 = 2), gen(inv2)
tab inv2 [aw=weight]
frame change JulOct
recode involvement_w1 (1/2 = 1)(3/4 = 2), gen(inv2_w1)
recode involvement_w2 (1/2 = 1)(3/4 = 2), gen(inv2_w2)
tab inv2_w1
tab inv2_w2

*******************************
* regression models (table 3) *
*******************************
eststo clear
frame change April
qui eststo: reg involvement health_fear econ_fear ///
	ib2.bloc ///
	sex age_group income ib4.religiosity [w=weight]
frame change JulOct
eststo: qui reg involvement_w1 ///
		health_concern_w1 econ_concern_w1 diagnosed_w1 quarantined_w1 econ_change_w1 ///
		left_right ///
		sex age_group education income ib4.religiosity 
eststo: qui reg involvement_w2 ///
		health_concern_w2 econ_concern_w2 diagnosed_w2 quarantined_w2 econ_change_w2 ///
		left_right  ///
		sex age_group education income ib4.religiosity
esttab, ///
	se(3) b(3) r2(3) ///
	drop(sex age_group education income *religiosity 2.bloc _cons) ///
	rename(health_fear health health_concern_w1 health health_concern_w2 health ///
		econ_fear econ econ_concern_w1 econ econ_concern_w2 econ ///
		diagnosed_w1 diagnosed diagnosed_w2 diagnosed ///
		quarantined_w1 quarantined quarantined_w2 quarantined ///
		econ_change_w1 econ_change econ_change_w2 econ_change) ///
	coeflabels(health "Health Concern" econ "Economic Concern" ///
		diagnosed "Diagnosed" quarantined "Quarantined" econ_change "Economic loss" ///
		1.bloc "Left-Right (Vote): Left" 3.bloc "Left-Right (Vote): Right" ///
		left_right "Left-Right (Self-identification)") ///
	order(health econ diagnosed quarantined econ_change	1.bloc 3.bloc left_right) ///
	mtitles("April" "July" "October") ///
	nogaps compress 

**************************
* Full models (table A3) *
**************************
eststo clear
frame change April
qui eststo: reg involvement health_fear econ_fear ///
	ib2.bloc ///
	sex age_group income ib4.religiosity [w=weight]
frame change JulOct
eststo: qui reg involvement_w1 ///
		health_concern_w1 econ_concern_w1 diagnosed_w1 quarantined_w1 econ_change_w1 ///
		left_right ///
		sex age_group education income ib4.religiosity 
eststo: qui reg involvement_w2 ///
		health_concern_w2 econ_concern_w2 diagnosed_w2 quarantined_w2 econ_change_w2 ///
		left_right  ///
		sex age_group education income ib4.religiosity
esttab, ///
	se(3) b(3) r2(3) ///
	drop(4.religiosity 2.bloc) ///
	rename(health_fear health health_concern_w1 health health_concern_w2 health ///
		econ_fear econ econ_concern_w1 econ econ_concern_w2 econ ///
		diagnosed_w1 diagnosed diagnosed_w2 diagnosed ///
		quarantined_w1 quarantined quarantined_w2 quarantined ///
		econ_change_w1 econ_change econ_change_w2 econ_change) ///
	coeflabels(health "Health Concern" econ "Economic Concern" ///
		diagnosed "Diagnosed" quarantined "Quarantined" econ_change "Economic loss" ///
		1.bloc "Left-Right (Vote): Left" 3.bloc "Left-Right (Vote): Right" ///
		left_right "Left-Right (Self-identification)" ///
		sex "Sex:Female" age_group "Age Group" income "Income" ///
		1.religiosity "Religiosity: Ultra-Orthodox" ///
		2.religiosity "Religiosity: Orthodox" ///
		3.Religiosity "Religiosity: Traditional" ///
		education "Education" _cons "Constant") ///
	order(health econ diagnosed quarantined econ_change	1.bloc 3.bloc left_right ///
		sex age_group income 1.religiosity 2.religiosity 3.religiosity education) ///
	mtitles("April" "July" "October") ///
	nogaps compress 
	
	
***************************************************
* robustnes tests (tables A12-A17, fiugres A1-A2) *
***************************************************
frame change JulOct
** robustness: individual-level change in threat perceptions
* paired t-test for change in willingness to help 
ttest involvement_w2==involvement_w1
* regression with change (October - July) (table A12)
eststo clear
eststo: qui reg involvement_w2 ///
		health_concern_delta econ_concern_delta diagnosed_w2 quarantined_w2 econ_change_w2 ///
		left_right  ///
		sex age_group education ib9.religiosity income
eststo: qui reg involvement_w2 ///
		health_concern_delta econ_concern_delta diagnosed_delta quarantined_delta econ_change_delta ///
		left_right  ///
		sex age_group education ib9.religiosity income
eststo: qui reg involvement_delta ///
		health_concern_delta econ_concern_delta diagnosed_w2 quarantined_w2 econ_change_w2 ///
		left_right  ///
		sex age_group education ib9.religiosity income
eststo: qui reg involvement_delta ///
		health_concern_delta econ_concern_delta diagnosed_delta quarantined_delta econ_change_delta ///
		left_right  ///
		sex age_group education ib9.religiosity income
esttab, ///
	se(3) b(3) r2(3) ///
	drop(sex age_group education income *religiosity _cons) ///
	rename(diagnosed_w1 diagnosed diagnosed_w2 diagnosed ///
		quarantined_w1 quarantined quarantined_w2 quarantined ///
		econ_change_w1 econ_change econ_change_w2 econ_change) ///
	coeflabels(health_concern_delta "Health Concern (Change)" ///
		econ_concern_delta "Economic Concern (Change)" ///
		diagnosed_delta "Diagnosed (Change)" quarantined_delta "Quarantined (Change)" ///
		econ_change_delta "Economic Loss (Change)" ///
		diagnosed "Diagnosed" quarantined "Quarantined" econ_change "Economic loss" ///
		left_right "Left-Right (Self-identification)") ///
	order(health_concern_delta econ_concern_delta diagnosed diagnosed_delta ///
		quarantined quarantined_delta econ_change econ_change_delta left_right) ///
	mtitles("Involvement" "Involvement" "Change in Involvement" "Change in Involvement") ///
	nogaps compress 

** locality-level cumulative infection rates during survey (table A13)
frame change JulOct
eststo clear
eststo: qui reg involvement_w1 ///
		health_concern_w1 econ_concern_w1 diagnosed_w1 quarantined_w1 econ_change_w1 ///
		left_right  ///
		sex age_group education income ib4.religiosity 
eststo: qui reg involvement_w1 ///
		health_concern_w1 econ_concern_w1 diagnosed_w1 quarantined_w1 econ_change_w1 ///
		left_right  ///
		sex age_group education income ib4.religiosity local_cases_jul
eststo: qui reg involvement_w2 ///
		health_concern_w2 econ_concern_w2 diagnosed_w2 quarantined_w2 econ_change_w2 ///
		left_right  ///
		sex age_group education ib4.religiosity income
eststo: qui reg involvement_w2 ///
		health_concern_w2 econ_concern_w2 diagnosed_w2 quarantined_w2 econ_change_w2 ///
		left_right  ///
		sex age_group education ib4.religiosity income local_cases_oct
esttab, ///
	se(3) b(3) r2(3) ///
	drop(sex age_group education income *religiosity _cons) ///
	rename(health_concern_w1 health health_concern_w2 health ///
		econ_concern_w1 econ econ_concern_w2 econ ///
		diagnosed_w1 diagnosed diagnosed_w2 diagnosed ///
		quarantined_w1 quarantined quarantined_w2 quarantined ///
		econ_change_w1 econ_change econ_change_w2 econ_change ///
		local_cases_jul local local_cases_oct local) ///
	coeflabels(health "Health Concern" econ "Economic Concern" ///
		diagnosed "Diagnosed" quarantined "Quarantined" econ_change "Economic loss" ///
		left_right "Left-Right (Self-identification)" local "Local COVID-19 Cases") ///
	order(health econ diagnosed quarantined econ_change local left_right) ///
	mtitles("Original" "Local Exposure" "Original" "Local Exposure") ///
	mgroups("July" "October", pattern(1 0 1 0)) ///
	nogaps compress 	
	
** robustness: only Jerusalemites and settlers (table A14)
eststo clear
frame change April
qui eststo: reg involvement health_fear econ_fear ib2.bloc sex age_group income ib4.religiosity [w=weight] if jer_wb==1
frame change JulOct
eststo: qui reg involvement_w1 ///
		health_concern_w1 econ_concern_w1 diagnosed_w1 quarantined_w1 econ_change_w1 ///
		left_right  ///
		sex age_group education income ib4.religiosity if jer_wb==1
eststo: qui reg involvement_w2 ///
		health_concern_w2 econ_concern_w2 diagnosed_w2 quarantined_w2 econ_change_w2 ///
		left_right  ///
		sex age_group education ib4.religiosity income if jer_wb==1
esttab, ///
	se(3) b(3) r2(3) ///
	drop(sex age_group education income *religiosity 2.bloc _cons) ///
	rename(health_fear health health_concern_w1 health health_concern_w2 health ///
		econ_fear econ econ_concern_w1 econ econ_concern_w2 econ ///
		diagnosed_w1 diagnosed diagnosed_w2 diagnosed ///
		quarantined_w1 quarantined quarantined_w2 quarantined ///
		econ_change_w1 econ_change econ_change_w2 econ_change) ///
	coeflabels(health "Health Concern" econ "Economic Concern" ///
		diagnosed "Diagnosed" quarantined "Quarantined" econ_change "Economic loss" ///
		1.bloc "Left-Right (Vote): Left" 3.bloc "Left-Right (Vote): Right" ///
		left_right "Left-Right (Self-identification)") ///
	order(health econ diagnosed quarantined econ_change	1.bloc 3.bloc left_right) ///
	mtitles("April" "July" "October") ///
	nogaps compress 

** robustness: interactions
* regressions (table A15)
eststo clear
frame change April
qui eststo: reg involvement ///
	ib2.bloc##c.health_fear ib2.bloc##c.econ_fear ///
	sex age_group income ib4.religiosity [w=weight]
frame change JulOct
qui eststo: reg involvement_w1 ///
	c.left_right##c.health_concern_w1 c.left_right##c.econ_concern_w1  ///
	diagnosed_w1 quarantined_w1 econ_change_w1 ///
	sex age_group education income ib9.religiosity 
qui eststo: reg involvement_w2 ///
	c.left_right##c.health_concern_w2 c.left_right##c.econ_concern_w2  ///
	diagnosed_w2 quarantined_w2 econ_change_w2 ///
	sex age_group education income ib9.religiosity 
esttab, ///
	se(3) b(3) r2(3) ///
	drop(sex age_group education income *religiosity _cons) ///
	rename(health_fear health health_concern_w1 health health_concern_w2 health ///
		econ_fear econ econ_concern_w1 econ econ_concern_w2 econ ///
		diagnosed_w1 diagnosed diagnosed_w2 diagnosed ///
		quarantined_w1 quarantined quarantined_w2 quarantined ///
		econ_change_w1 econ_change econ_change_w2 econ_change ///
		c.left_right#c.health_concern_w1 lr_health ///
		c.left_right#c.health_concern_w2 lr_health ///
		c.left_right#c.econ_concern_w1 lr_econ ///
		c.left_right#c.econ_concern_w2 lr_econ) ///
	coeflabels(health "Health Concern" econ "Economic Concern" ///
		diagnosed "Diagnosed" quarantined "Quarantined" econ_change "Economic loss" ///
		1.bloc "Left-Right (Vote): Left" 3.bloc "Left-Right (Vote): Right" ///
		left_right "Left-Right (Self-identification)" ///
		1.bloc#c.health_fear "L-R (Vote L) × Heal. Conc." ///
		3.bloc#c.health_fear "L-R (Vote R) × Heal. Conc." ///
		1.bloc#c.econ_fear "L-R (Vote L) × Econ. Conc." ///
		3.bloc#c.econ_fear "L-R (Vote R) × Econ. Conc." ///
		lr_health "L-R (Self-id.) × Heal. Conc." ///
		lr_econ "L-R (Self-id.) × Econ. Conc.") ///
	order(1.bloc 3.bloc left_right health econ diagnosed quarantined econ_change ///
		1.bloc#c.health_fear 3.bloc#c.health_fear ///
		1.bloc#c.econ_fear 3.bloc#c.econ_fear ///
		lr_health lr_econ) ///
	mtitles("April" "July" "October") ///
	nogaps compress nobaselevels noomitted
* marginal effect plots for terms with significance
	* April survey, health concerns*bloc (figure A1)
	frame change April
	qui reg involvement ///
		ib2.bloc##c.health_fear ib2.bloc##c.econ_fear ///
		sex age_group income ib4.religiosity [w=weight]
	margins, dydx(health_fear) at(bloc=(1(1)3)) 
	marginsplot, yline(0)
	* July survey, health concerns*left-right (figure A2)
	frame change JulOct
	qui reg involvement_w1 ///
		c.left_right##c.health_concern_w1 c.left_right##c.econ_concern_w1  ///
		diagnosed_w1 quarantined_w1 econ_change_w1 ///
		sex age_group education income ib9.religiosity 
	margins, dydx(health_concern) at(left_right=(1(1)7)) 
	marginsplot, yline(0)
	
** robustness: independence of threat and partisanship
* prospective concerns (table A16)
eststo clear
frame change April
qui eststo: reg health_fear  ///
	ib2.bloc ///
	sex age_group income ib4.religiosity [w=weight]
qui eststo: reg econ_fear ///
	ib2.bloc ///
	sex age_group income ib4.religiosity [w=weight]
frame change JulOct
eststo: qui reg health_concern_w1 ///
		left_right ///
		sex age_group education income ib4.religiosity 
eststo: qui reg econ_concern_w1  ///
		left_right ///
		sex age_group education income ib4.religiosity 
eststo: qui reg health_concern_w2 ///
		left_right ///
		sex age_group education income ib4.religiosity 
eststo: qui reg econ_concern_w2  ///
		left_right ///
		sex age_group education income ib4.religiosity 
esttab, ///
	se(3) b(3) r2(3) ///
	drop (2.bloc 4.religiosity) ///
	coeflabels(health "Health Concern" econ "Economic Concern" ///
		diagnosed "Diagnosed" quarantined "Quarantined" econ_change "Economic loss" ///
		1.bloc "Left-Right (Vote): Left" 3.bloc "Left-Right (Vote): Right" ///
		left_right "Left-Right (Self-identification)" ///
		sex "Sex:Female" age_group "Age Group" income "Income" ///
		1.religiosity "Religiosity: Ultra-Orthodox" ///
		2.religiosity "Religiosity: Orthodox" ///
		3.Religiosity "Religiosity: Traditional" ///
		education "Education" _cons "Constant") ///
	order(1.bloc 3.bloc left_right ///
		sex age_group income 1.religiosity 2.religiosity 3.religiosity education) ///
	mtitles("Health" "Economic" "Health" "Economic" "Health" "Economic") ///
	mgroups("April" "July" "October", pattern(1 0 1 0 1 0)) ///
	nogaps compress 
* retrosepctive harm (table A17)
eststo clear
frame change JulOct
	eststo: qui reg diagnosed_w1 ///
		left_right ///
		sex age_group education income ib4.religiosity 
	eststo: qui reg quarantined_w1  ///
		left_right ///
		sex age_group education income ib4.religiosity 
	eststo: qui reg local_cases_jul ///
		left_right ///
		sex age_group education income ib4.religiosity 
	eststo: qui reg diagnosed_w2 ///
		left_right ///
		sex age_group education income ib4.religiosity 
	eststo: qui reg quarantined_w2  ///
		left_right ///
		sex age_group education income ib4.religiosity 
	eststo: qui reg local_cases_oct ///
		left_right ///
		sex age_group education income ib4.religiosity 
esttab, ///
	b(3) se(3) r2 ///
	drop (4.religiosity) ///
	coeflabels(sex "Sex: Female" age_group "Age Group" income "Income" ///
		1.religiosity "Religiosity: Ultra-Orthodox" ///
		2.religiosity "Religiosity: Orthodox" 3.religiosity "Religiosity: Traditional" ///
		left_right "Left-Right (Self-identification)" ///
		education "Education" _cons "Constant") ///
	mtitles("Diagnosed" "Quarentined" "Caseload" "Diagnosed" "Quarentined" "Caseload") ///
	mgroups("July" "October", pattern(1 0 0 1 0 0)) ///
	nogaps compress